package com.nbjtjc.safe.service.cost;

import java.util.List;

import cn.hutool.core.collection.CollectionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.mapper.cost.CostBudgetMonthMapper;
import com.nbjtjc.safe.model.cost.CostBudgetMonth;
import com.nbjtjc.safe.model.cost.CostBudgetPlan;

import cn.hutool.core.util.ObjectUtil;

@Service
public class CostBudgetMonthService {
	@Autowired
	  private CostBudgetMonthMapper costBudgetMonthMapper;
	
	  public Result findByPlanId(CostBudgetPlan costBudgetPlan){
		  Result result = new Result();
		  
		  if(ObjectUtil.isNotNull(costBudgetPlan)&&ObjectUtil.isNotNull(costBudgetPlan.getId())){
//			  List<CostBudgetMonth> costBudgetMonths = costBudgetMonthMapper.findPlanByPlanId(costBudgetPlan.getId());
			  CostBudgetMonth costBudgetMonth = costBudgetMonthMapper.findPlanByPlanId(costBudgetPlan.getId());
			  result.setData(costBudgetMonth);

//			  if(CollectionUtil.isNotEmpty(costBudgetMonths)){
//				  result.setData(costBudgetMonths.get(0));
//			  }
		  }else{
			  result.setFalse("传入的预算计划ID为空");
			  return result;
		  }
		  
		  return result;
	  }
	
}
